home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / AvantBrowser / asetup.exe / _data / webkit / resources.pak / Unnamed File 000077.txt < prev    next >
Text File  |  2013-04-03  |  3KB  |  121 lines

  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4.  
  5. /**
  6.  * @fileoverview This is a table column representation
  7.  */
  8.  
  9. cr.define('cr.ui.table', function() {
  10.   /** @const */ var EventTarget = cr.EventTarget;
  11.   /** @const */ var Event = cr.Event;
  12.  
  13.   /**
  14.    * A table column that wraps column ids and settings.
  15.    * @param {!Array} columnIds Array of column ids.
  16.    * @constructor
  17.    * @extends {EventTarget}
  18.    */
  19.   function TableColumn(id, name, width, endAlign) {
  20.     this.id_ = id;
  21.     this.name_ = name;
  22.     this.width_ = width;
  23.     this.endAlign_ = endAlign;
  24.   }
  25.  
  26.   TableColumn.prototype = {
  27.     __proto__: EventTarget.prototype,
  28.  
  29.     id_: null,
  30.  
  31.     name_: null,
  32.  
  33.     width_: null,
  34.  
  35.     endAlign_: false,
  36.  
  37.     defaultOrder_: 'asc',
  38.  
  39.     /**
  40.      * Clones column.
  41.      * @return {cr.ui.table.TableColumn} Clone of the given column.
  42.      */
  43.     clone: function() {
  44.       var tableColumn = new TableColumn(this.id_, this.name_, this.width_,
  45.                                         this.endAlign_);
  46.       tableColumn.renderFunction = this.renderFunction_;
  47.       tableColumn.headerRenderFunction = this.headerRenderFunction_;
  48.       tableColumn.defaultOrder = this.defaultOrder_;
  49.       return tableColumn;
  50.     },
  51.  
  52.     /**
  53.      * Renders table cell. This is the default render function.
  54.      * @param {*} dataItem The data item to be rendered.
  55.      * @param {string} columnId The column id.
  56.      * @param {cr.ui.Table} table The table.
  57.      * @return {HTMLElement} Rendered element.
  58.      */
  59.     renderFunction_: function(dataItem, columnId, table) {
  60.       var div = table.ownerDocument.createElement('div');
  61.       div.textContent = dataItem[columnId];
  62.       return div;
  63.     },
  64.  
  65.     /**
  66.      * Renders table header. This is the default render function.
  67.      * @param {cr.ui.Table} table The table.
  68.      * @return {HTMLElement} Rendered element.
  69.      */
  70.     headerRenderFunction_: function(table) {
  71.       return table.ownerDocument.createTextNode(this.name);
  72.     },
  73.   };
  74.  
  75.   /**
  76.    * The column id.
  77.    * @type {string}
  78.    */
  79.   cr.defineProperty(TableColumn, 'id');
  80.  
  81.   /**
  82.    * The column name
  83.    * @type {string}
  84.    */
  85.   cr.defineProperty(TableColumn, 'name');
  86.  
  87.   /**
  88.    * The column width.
  89.    * @type {number}
  90.    */
  91.   cr.defineProperty(TableColumn, 'width');
  92.  
  93.   /**
  94.    * True if the column is aligned to end.
  95.    * @type {boolean}
  96.    */
  97.   cr.defineProperty(TableColumn, 'endAlign');
  98.  
  99.   /**
  100.    * The column render function.
  101.    * @type {Function(*, string, cr.ui.Table): HTMLElement}
  102.    */
  103.   cr.defineProperty(TableColumn, 'renderFunction');
  104.  
  105.   /**
  106.    * The column header render function.
  107.    * @type {Function(cr.ui.Table): HTMLElement}
  108.    */
  109.   cr.defineProperty(TableColumn, 'headerRenderFunction');
  110.  
  111.   /**
  112.    * Default sorting order for the column ('asc' or 'desc').
  113.    * @type {string}
  114.    */
  115.   cr.defineProperty(TableColumn, 'defaultOrder');
  116.  
  117.   return {
  118.     TableColumn: TableColumn
  119.   };
  120. });
  121.